#include <iostream>
#include <memory>

class Camera{
public:
    virtual ~Camera(){}
    virtual int get_frame() = 0;
};

class BaslerCamera: public Camera{
public:
    int get_frame(){
        std::cout << "basler get frame" << std::endl;
        return 1;
    }

    ~BaslerCamera(){
        std::cout << "basler free" << std::endl;
    }
};

class FleaCamera: public Camera{
public:
    int get_frame(){
         std::cout << "flea get frame" << std::endl;
         return 2;
     }

    ~FleaCamera(){
        std::cout << "flea free" << std::endl;
    }
};

typedef std::shared_ptr<Camera> CameraP;
class CameraManager{
public:
    static CameraP get_camera(const std::string& _camera_name){
        if("basler" == _camera_name){
            return std::make_shared<BaslerCamera>();
        }
        else if("flea" == _camera_name){
            return std::make_shared<FleaCamera>();
        }
        else
            return nullptr;
    }
};

int main(){
    CameraP camera = CameraManager::get_camera("basler");
    camera->get_frame();

    camera = CameraManager::get_camera("flea");
    camera->get_frame();
}
